package com.cskaoyan.dbutils;

import com.cskaoyan.bean.Account;
import com.cskaoyan.connectionpool.dbcp.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;

import javax.sql.DataSource;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * 创建日期: 2022/07/28 16:43
 *
 * @author ciggar
 */
public class QueryDemo1 {

    public static void main(String[] args) throws SQLException {


        // 获取数据库连接池
        DataSource dataSource = DruidUtils.getDataSource();

        // 构建QueryRunner
        QueryRunner queryRunner = new QueryRunner(dataSource);

        // 执行SQL语句
        Account account = queryRunner.query("select * from account where id = ?", new MyResultSetHandler(), 1002);


        System.out.println(account);

    }


}
